import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FeedbackInfoVO, FeedbackInfoForm, FeedbackInfoQuery } from '@/api/workorder/feedbackInfo/types';

/**
 * 查询投诉意见列表
 * @param query
 * @returns {*}
 */

export const listFeedbackInfo = (query?: FeedbackInfoQuery): AxiosPromise<FeedbackInfoVO[]> => {
  return request({
    url: '/workorder/feedbackInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询投诉意见详细
 * @param id
 */
export const getFeedbackInfo = (id: string | number): AxiosPromise<FeedbackInfoVO> => {
  return request({
    url: '/workorder/feedbackInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增投诉意见
 * @param data
 */
export const addFeedbackInfo = (data: FeedbackInfoForm) => {
  return request({
    url: '/workorder/feedbackInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改投诉意见
 * @param data
 */
export const updateFeedbackInfo = (data: FeedbackInfoForm) => {
  return request({
    url: '/workorder/feedbackInfo',
    method: 'put',
    data: data
  });
};

export const replyFeedbackInfo = (data: FeedbackInfoForm) => {
  return request({
    url: '/workorder/feedbackInfo/reply',
    method: 'put',
    data: data
  });
};

/**
 * 删除投诉意见
 * @param id
 */
export const delFeedbackInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/workorder/feedbackInfo/' + id,
    method: 'delete'
  });
};
